package com.breaking.second.activity.pager.adapter;


import android.content.Context;

import androidx.annotation.NonNull;
import androidx.core.content.ContextCompat;

import com.breaking.second.databinding.ItemMyToolBinding;
import com.breaking.second.entity.MyToolEntity;

import java.util.List;

public class MyToolAdapter extends BaseAdapter<ItemMyToolBinding> {
    private final List<MyToolEntity> myToolEntities;

    public MyToolAdapter(Context context, List<MyToolEntity> myToolEntities) {
        super(context);
        this.myToolEntities = myToolEntities;
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        ItemMyToolBinding binding = ItemMyToolBinding.bind(holder.itemView);
        MyToolEntity entity = myToolEntities.get(position);
        binding.text.setText(entity.getTitle());
        binding.image.setImageDrawable(ContextCompat.getDrawable(getContext(), entity.getDrawable()));
    }

    @Override
    public int getItemCount() {
        return myToolEntities.size();
    }
}
